package com.cyandpos.pad.posdata;


import com.cyandpos.pad.utils.MoneyUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2020/2/catering_main_open_table.
 */

public class Payment implements Serializable{

    public static final int SKFS_NORMAL = 0; // 现金
    public static final int SKFS_CREDITCARD = 1; // 信用卡
    public static final int SKFS_CZK = 2; // 储值卡
    public static final int SKFS_YHQ = 3; // 纸券
    public static final int SKFS_YHQK = 4; // 卡券
    public static final int SKFS_ZP = 6; // 支票
    public static final int SKFS_YHK = 7; // 银行卡
    public static final int SKFS_FQBC = 10; // 返券补差
    public static final int SKFS_MBDY = 16; // 满百抵用
    public static final int SKFS_JH= 12; // 聚合支付
    public static final int SKFS_WX = 18; // 微信
    public static final int SKFS_ZFB = 19; // 支付宝
    public static final int SKFS_QMF = 17; // 钱买分收款方式
    public static final int SKFS_DJD = 7571;

    private int payCode;//	代码(id)
    private int payType;//	类型
    private String payAmount;//付款金额(元)
    private String payName;//	名称
    private int changeType;//	找零方式
    private int yhqId;//	优惠券id
    private int xssx;//	显示顺序
    private String overflowAmount;//溢余金额(元)
    private int isCoded;//是否是编码券isCoded  1 是     0不是

    private List<PayInfo> payInfoList;
    private List<DjdInfo> djdInfoList;//订金单详情列表

    public List<DjdInfo> getDjdInfoList() {
        return djdInfoList;
    }

    public void setDjdInfoList(List<DjdInfo> djdInfoList) {
        this.djdInfoList = djdInfoList;
    }

    public Payment() {
        payInfoList=new ArrayList<>();
        djdInfoList=new ArrayList<>();
    }

    public Payment(int type) {
        setPayType(type);
    }

    public int getPayCode() {
        return payCode;
    }

    public void setPayCode(int payCode) {
        this.payCode = payCode;
    }

    public String getPayName() {
        return payName;
    }

    public void setPayName(String payName) {
        this.payName = payName;
    }

    public int getPayType() {
        return payType;
    }

    public void setPayType(int payType) {
        this.payType = payType;
    }

    public int getChangeType() {
        return changeType;
    }

    public void setChangeType(int changeType) {
        this.changeType = changeType;
    }

    public int getYhqId() {
        return yhqId;
    }

    public void setYhqId(int yhqId) {
        this.yhqId = yhqId;
    }

    public int getXssx() {
        return xssx;
    }

    public void setXssx(int xssx) {
        this.xssx = xssx;
    }

    public String getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(String payAmount) {
        this.payAmount = payAmount;
    }

    public String getOverflowAmount() {
        return overflowAmount;
    }

    public void setOverflowAmount(String overflowAmount) {
        this.overflowAmount = overflowAmount;
    }

    public int getIsCoded() {
        return isCoded;
    }

    public void setIsCoded(int isCoded) {
        this.isCoded = isCoded;
    }

    public List<PayInfo> getPayInfoList() {
        return payInfoList;
    }

    public void setPayInfoList(List<PayInfo> payInfoList) {
        this.payInfoList = payInfoList;
    }


    @Override
    public String toString() {
        return "Payment{" +
                "payCode=" + payCode +
                ", payType=" + payType +
                ", payAmount='" + payAmount + '\'' +
                ", payName='" + payName + '\'' +
                ", changeType=" + changeType +
                ", yhqId=" + yhqId +
                ", xssx=" + xssx +
                ", overflowAmount='" + overflowAmount + '\'' +
                '}';
    }

    public int PayProc(int other, int input, int total) {// 每个子类都会有的处理方法

        if (getChangeType() == 0) {
            if ((total + 10000) < (other + input)) {
                return 1;
            } // 找零金额不能大于100元
            else {
                setPayAmount(MoneyUtils.getMoneyStr(input));
            }
        } else if (getChangeType() == 1) {
            if ((total) < (other + input)) {
                return 2;
            } // 不能多收
            else {
                setPayAmount(MoneyUtils.getMoneyStr(input));
            }
        } else if (getChangeType() == 2) {
            setPayAmount(MoneyUtils.getMoneyStr(input > (total - other) ? (total - other) : input)); // 多收金额算到溢余金额中
            setOverflowAmount(MoneyUtils.getMoneyStr(input > (total - other) ? (input + other - total) : 0)); //不知道客户端现在需要处理否
        }
        return 0;
    }


}
